/*
 * @Description: 
 * @Author: 赵大壮
 * @Date: 2021-12-06 17:18:37
 * @LastEditTime: 2021-12-06 17:36:29
 * @LastEditors: 赵大壮
 */
import { Component, Vue, Inject } from "vue-property-decorator";
import DZServiceAdmin from "../../service/DZServiceAdmin";
import DZModelRole from "../../model/DZModelRole";
import UiDialogAddRole from "@/components/ui-dialog/UiDialogAddRole.vue";

@Component({
    components: { UiDialogAddRole }
})
export default class Index extends Vue {

    s_admin = new DZServiceAdmin();

    dialog_add_role = false;

    created() {
        this.action_list_role();
    }

    mounted() {

    }

    beforeDestroy() {

    }

    action_list_role() {
        this.s_admin.net_list_role();
    }

    action_show_dialog() {
        this.dialog_add_role = true;
        this.s_admin.m_role = new DZModelRole();
    }

    action_add_role(data: DZModelRole) {
        this.s_admin.m_role = JSON.parse(JSON.stringify(data));
        if (this.s_admin.m_role.iId) {
            this.s_admin.net_edit_role(() => {
                this.action_list_role();
            });
        } else {
            this.s_admin.net_add_role(() => {
                this.action_list_role();
            });
        }
    }

    action_edit_data(data: DZModelRole) {
        this.s_admin.m_role = JSON.parse(JSON.stringify(data));
        this.dialog_add_role = true;
    }

    action_operate_role(data: DZModelRole) {
        this.s_admin.net_operate_role(data.iId, () => {
            this.action_list_role();
        })
    }

    action_del_role(data: DZModelRole) {
        this.s_admin.net_del_role(data.iId, () => {
            this.action_list_role();
        })
    }
}